#include <vector>
#include <iostream>

using namespace std;
class Solution 
{
public:
	vector<vector<int> > generateMatrix(int n)
	{
		// Start typing your C/C++ solution below
		// DO NOT write int main() function
		
		
		if(n<=0)
			return vector<vector<int> >();

		vector<vector<int> > result(n);
		for(int i=0;i<n;i++)
			result[i] = vector<int>(n);
		


		int nsteps[4] = {n-1,n-1,n-1,n-2};
		int steps[4][2] = {{0,1},{1,0},{0,-1},{-1,0}};
		int curIdx = 1, x = 0, y = 0;
		while(curIdx<=(n*n))
		{
			result[x][y] = curIdx++;
			for(int i=0;i<4;i++)
			{
				if(curIdx>(n*n))
					return result;
				for(int j=0;j<nsteps[i];j++,curIdx++)
				{
					x += steps[i][0];
					y += steps[i][1];
					result[x][y] = curIdx;					
				}
				nsteps[i] -= 2;
			}
			y++;
		};

		return result;
	}
};
int main()
{
	int n;
	Solution s;
	while(cin>>n)
	{
		if(n<=0)
			break;

		vector<vector<int> >  r = s.generateMatrix(n);
		for(size_t i=0;i<r.size();i++)
		{
			for(size_t j=0;j<r[i].size();j++)
				cout<<r[i][j]<<" ";
			cout<<endl;
		}
	}
}